{include file="public/_meta" /}
<title></title>
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add"> 
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>标题：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" name="title">
		</div>
	</div>
<!--	<div class="row cl">-->
<!--		<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>摘要：</label>-->
<!--		<div class="formControls col-xs-8 col-sm-9">-->
<!--			<input type="text" class="input-text" value="" name="summary">-->
<!--		</div>-->
<!--	</div>-->
	<div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>标题图片：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div style="width:110px;height: 110px;position: relative;display: inline-block; ">
                        <img src="/static/admin/img/add0.png" alt="" class="logo" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;">
                        <input type="file" name="file" onchange="eee($(this))" class="input-text" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;">
                    </div>
                </div>
            </div>
            <div style="display:none" class="ttt">
                <input type="text" name="pic" value="">
            </div>

	<div class="row cl">
        <label class="form-label col-xs-4 col-sm-2">内容：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <textarea id="editor" type="text/plain" style="width:100%;height:400px;" name="content" >
            </textarea>
        </div>
    </div>
	<!-- <div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>内容：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<textarea name="content" cols="150" rows="20"></textarea>
		</div>
	</div> -->
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" onclick="return add()">
		</div>
	</div>
	</form>
</article>

{include file="public/_footer"/}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/static/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
//     $(function() {
//         var ue = UE.getEditor('editor');
        
//         $('.skin-minimal input').iCheck({
//             checkboxClass: 'icheckbox-blue',
//             radioClass: 'iradio-blue',
//             increaseArea: '20%'
//         }); 
// <script type="text/javascript">
$(function(){
	var ue = UE.getEditor('editor');
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
});


function add(){

	$.post("{:url('add')}",$('form').serialize()).success(function(data){
		layer.msg(data.msg);
		if(data.code){
			setTimeout(function(){
				//location.href=reload();
				location.href='';
			},1000);
			
		}
	});
	return false;
}
function eee(dada) {
        var data = new FormData();
        data.append('file', dada[0].files[0]);
        var index = layer.load(1, { shade: false }); //0代表加载的风格，支持0-2
        $.ajax({
            url: '{:url("upload")}',
            type: 'POST',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
                layer.msg(data.msg);
                if (data.code) {
                    $('.logo').attr('src',data.data);
                    $('input[name="pic"]').val(data.data);
                }
                layer.close(index);
            },
            error: function(data) {
            	//console.log(data)
                layer.close(index);
                layer.msg('上传出错');
            }
        });
    }

</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>